<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<ng-container *ngIf="!showContextPathForm; else contextPathForm">
  <span mat-dialog-title>Add your API entrypoints</span>

  <form *ngIf="formGroup" [formGroup]="formGroup" (ngSubmit)="save()">
    <mat-dialog-content>
      <p>Choose how your users will consume your API</p>
      <gio-entrypoints-selection-list formControlName="selectedEntrypointsIds" [entrypoints]="entrypoints"></gio-entrypoints-selection-list>

      <div *ngIf="requiresUpgrade" class="license-banner">
        <gio-license-banner
          [license]="license$ | async"
          [isOEM]="isOEM$ | async"
          (onRequestUpgrade)="onRequestUpgrade()"
        ></gio-license-banner>
      </div>
    </mat-dialog-content>
    <mat-dialog-actions class="actions">
      <button mat-stroked-button type="button" (click)="cancel()">Cancel</button>
      <button mat-flat-button color="primary" type="submit" [disabled]="formGroup.invalid">Add API entrypoints</button>
    </mat-dialog-actions>
  </form>
</ng-container>
<ng-template #contextPathForm>
  <mat-dialog-content>
    <div class="header">
      <h3>Configure your context-paths</h3>
      <p>Configure at least one context-path for your API before adding this entrypoint</p>
    </div>
    <form *ngIf="contextPathFormGroup" [formGroup]="contextPathFormGroup" (ngSubmit)="saveWithContextPath()">
      <gio-form-listeners-context-path formControlName="contextPath"></gio-form-listeners-context-path>
      <mat-dialog-actions class="actions">
        <button mat-stroked-button type="button" (click)="cancel()">Cancel</button>
        <button mat-flat-button color="primary" type="submit" [disabled]="contextPathFormGroup.invalid">Validate my entrypoints</button>
      </mat-dialog-actions>
    </form>
  </mat-dialog-content>
</ng-template>
